package com.molin.networkTest.socketTest.tcpTest.demo2;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket=new ServerSocket(8888);

        Socket accept = serverSocket.accept();
        InputStream inputStream = accept.getInputStream();

        int b;
        while ((b=inputStream.read())!=-1){
            System.out.print((char)b);
        }

        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("你是谁");
        bw.newLine();
        bw.flush();

        inputStream.close();
        accept.close();
        serverSocket.close();
    }
}
